/**
 * @author harae Feng 
 * @date 2019-09-12 10:26:17 
 * @Last Modified by: harae Feng
 * @Last Modified time: 2019-09-12 10:32:41
 * @Describe 获取当前运行IP信息
 */

 /**
  *获取当前IP
  *
  * @returns IP address
  */
 function getLocalIP(){
    let resultIP = ''
    const interfaces = require('os').networkInterfaces();
    for(var devName in interfaces){
        var iface = interfaces[devName];
        for(var i=0;i<iface.length;i++){
            var alias = iface[i];
            if(alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal){
                resultIP = alias.address;
            }
        }
    }
    return resultIP
 }

 const LocalIP = getLocalIP()
 const DefaultServerIP = `118.31.113.21`
 const isServerIP = (LocalIP === DefaultServerIP)   // 是否为服务器IP, 可用于判断是否应用为内网外网链接

 module.exports = {
     LocalIP: LocalIP,
     DefaultServerIP: DefaultServerIP,
     isServerIP: isServerIP,
 }